# coding:utf-8


class Code(object):
    def __init__(self, status, msg=''):
        self.status = status
        self.msg = msg

    def __str__(self):
        return "({status}, {msg})".format(code=self.status, msg=self.msg)

    def __repr__(self):
        return "({status}, {msg})".format(code=self.status, msg=self.msg)

    def new_format_msg(self, *args):
        """
        add by ld_wu
        用于需要格式化消息
        :param args:
        :return:
        """
        # 主要为了解决实例对象共用冲突问题
        return Code(self.status, self.msg % args)


SUCCESS = Code(200, 'Success')

UNAUTHORIZED = Code(401, 'Unauthorized')

USER_NOT_EXIST = Code(41007001, '用户不存在')

PARAMS_ILLEGAL = Code(41007012, '%s')

PRODUCT_ERROR = Code(41000001, '%s')

PRODUCT_NOT_FOUND = Code(41000002, '未找到相应的产品')
